package com.example.eurekaconsumer;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Service
public class ConsumerService {

    @Resource
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "helloServiceFallback")
    public String consumer() {
        return restTemplate.getForEntity("http://eureka-producer/hello", String.class).getBody();
    }

    public String helloServiceFallback() {
        return "error";
    }

}
